package com.tql.test_02;

public class Test1 {
    public static void main(String[] args) {
        Tockit tockit=new Tockit();
        new Thread(()->{
            for (int i = 0; i < 60; i++) {
                tockit.sale();
            }
        },"A").start();
        new Thread(()->{
            for (int i = 0; i < 60; i++) {
                tockit.sale();
            }
        },"B").start();
        new Thread(()->{
            for (int i = 0; i < 60; i++) {
                tockit.sale();
            }
        },"C").start();
    }
}
class Tockit{
    int num=50;
    public synchronized void sale(){
        if(num>0){
            System.out.println(Thread.currentThread().getName()+"正在售卖第"+(num--)+"张票，剩余"+num);
        }
    }
}
